﻿$(function () {
    //加载下拉框 状态
    $("#status").ligerComboBox({
        width: 80,
        data: [{ "ID": "", "Name": "全部" }, { "ID": 0, "Name": "未上报" }, { "ID": 1, "Name": "已上报" }],
        isMultiSelect: false,
        valueField: "ID",
        textField: "Name",
        value: "",
        valueFieldID: 'hdnstatus',
    });
    $('#btnSearch').click(function () {
        search();
    });
    $('#btnSearch').click();
});
$(document).keyup(function (event) {
    if (event.keyCode == 13) {
        $('#btnSearch').click();
    }
});
function opennewtab(patientId, patientName) {
    window.parent.top.tab.addTabItem({ tabid: patientId, text: "胸痛病历", url: "/ChestPainCenter/MedicalRecords/Index?patientId=" + patientId });
}
//查询功能
function search(pageNumber) {
    var queryData = {
        name: $("#txtName").val(),
        status: $("#hdnstatus").val()
    }
    initTable(queryData, 1);
}
//显示表数据
var grid;
function initTable(queryData, pageNumber) {
    grid = $("#maingrid").ligerGrid({
        checkbox: true,
        height: '100%',
        url: '/ReportStatus/Search?ram=' + new Date().getMilliseconds(),
        parms: queryData,
        page: pageNumber,
        pageSize: 30,
        rownumbers: false,
        heightDiff: -5,
        columns: [
{ display: '就诊ID', name: 'PATIENT_ID', minWidth: 50,width:150 },
{
    display: '姓名', name: 'PATIENT_NAME', minWidth: 100, width:120, render: function (row) {
        return "<a style=\"cursor:pointer;\" onclick=\"opennewtab('" + row.PATIENT_ID + "','" + row.PATIENT_NAME + "')\" >" + row.PATIENT_NAME + "</a>";
    }
},
{
    display: '性别', name: 'PATIENT_SEX', minWidth: 50, width:80,
    render: function (rowData) {
        if (typeof (rowData.PATIENT_SEX) == "undefined" || rowData.PATIENT_SEX == null || rowData.PATIENT_SEX == -1)
            return "未知";
        if (rowData.PATIENT_SEX == "0")
            return "男";
        if (rowData.PATIENT_SEX == "1")
            return "女";
        return rowData.PATIENT_SEX;
    }
},
{ display: '年龄', name: 'PATIENT_AGE', minWidth: 50, width: 80},
{
    display: '上报状态', name: 'ApprovalStatus', minWidth: 50,width:100,
    render: function (rowData) {
        if (typeof (rowData.ApprovalStatus) == "undefined" || rowData.ApprovalStatus == null || rowData.ApprovalStatus == "" || rowData.ApprovalStatus == "0")
            return "未上报";
        if (rowData.ApprovalStatus == "1")
            return "<span style=\"color:green\" >已上报</span>";
        if (rowData.ApprovalStatus == "2")
            return "<span style=\"color:green\" >已上报</span>";
        return "未上报";
    }
}],
        isScroll: true,
        onSuccess: function (data, grid) {
        }
    });
}
$(document).on("click", ".closeCls", function () {
    $("#btnSearch").click();
});

$("#btnReportStatus").click(function () {
    var rows = grid.getCheckedRows();
    var str = "";
    $(rows).each(function () {
        str += this.ID + ",";
    });
    if (str == "") return;
    str = str.substring(0, str.length - 1);
    if (str.length > 0)
        $.ligerDialog.success("上报成功");
});